<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/22
 * Time: 16:27
 */
namespace Api\Controller;
use Think\Controller;
use Think\Upload;

class ImagesController extends Controller {
    /**
     * 医生上传图片
     */
    public function upload_more($type){
        //上传图片
        $upSetting = C('UPLOADS');
        $data=[];
        $upload =new Upload();
        $upload->maxSize   =    $upSetting['SIZE'];// 设置附件上传大小
        $upload->exts      =    $upSetting['EXT'];// 设置附件上传类型
        $upload->rootPath  =     $upSetting['DIR']; // 设置附件上传根目录
        if($type==1){
            $upload->savePath  =     'Doctor/';//设置附件上传（子）目录
        }elseif($type==false){
            $upload->savePath  =     'Patient/';//设置附件上传（子）目录
        }
        //开始上传
        $filelist = $upload->upload();
        if(!$filelist) {
            //返回上传错误提示错误信息
            echo json_encode("请选择你要上传的图片");
        }else{
//            //上传成功
            foreach($filelist as $file){
                $arrays['photo']=$file['savepath'].$file['savename'];
                array_push($data,$arrays);
            }
            $datas['data']['file']=$data;
              echo  json_encode($datas);
        }

    }

}